import { createRouter, createWebHistory } from 'vue-router'
import SYView from '@/views/SYView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component:SYView
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/DLView.vue')
    },
    {
      path: '/gouwu',
      component: () => import('../views/GWView.vue')
    },
    //预约- 包厢 座位
    {
      path: '/yuyue',
      component: () => import('../views/yuyue/YYView.vue')
    },
    {
      path: '/zuowei',
      component: () => import('../views/yuyue/zuowei.vue')
    },{
      path: '/baoxiang',
      component: () => import('../views/yuyue/baoxiang.vue')
    },
    //资讯
    {
      path: '/zixun',
      component: () => import('../views/ZXView.vue')
    },
    {
      path: '/wode',
      component: () => import('../views/WDView.vue')
    }
  ]
})


//全局前置导航守卫
router.beforeEach((to, from, next) => {
  let isLogin = false
  if (to.path.indexOf('courseDetail') !== -1) {
    if (isLogin) {
      next()
    } else {
      next({ path: '/login' })
    }
  } else {
    next()
  }
})

export default router
